const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const FileManagerPlugin = require('filemanager-webpack-plugin')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
const path = require('path')

function resolve(dir) {
  return path.join(__dirname, '.', dir)
}
module.exports = {
  publicPath: '/',
  // outputDir: './Debug/Plugins/js-home',
  devServer: {
    hot: true,
    host: '127.0.0.1',
    port: 8083
    // proxy: {
    //   // 如果请求地址以/api打头,就出触发代理机制
    //   '/api': {
    //     target: 'https://comic.mkzcdn.com'
    //   }
    // }
  },
  lintOnSave: false, // 关闭Eslint
  productionSourceMap: false,
  css: {
    loaderOptions: {
      less: {
        globalVars: {
          hack: `true; @import '~@/assets/css/base.less';`
        }
      }
    }
  },
  configureWebpack: {
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()]
      }),
      Components({
        resolvers: [ElementPlusResolver()]
      }),
      //压缩文件插件
      new FileManagerPlugin({
        events: {
          onEnd: {
            delete: ['./dist.zip'],
            archive: [{ source: './dist', destination: './dist/dist.zip' }]
          }
        }
      })
    ]
  }
  // chainWebpack: (config) => {
  //   config.module.rules.delete("svg"); // 重点:删除默认配置中处理svg,
  //   config.module
  //     .rule("svg-sprite-loader")
  //     .test(/\.svg$/)
  //     .include.add(resolve("src/assets/svg-icons")) // 处理svg目录
  //     .end()
  //     .use("svg-sprite-loader")
  //     .loader("svg-sprite-loader")
  //     .options({
  //       symbolId: "icon-[name]",
  //     });
  // },
}
